package consume.dead;

import com.rabbitmq.client.Channel;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.amqp.support.AmqpHeaders;
import org.springframework.messaging.handler.annotation.Header;
import org.springframework.stereotype.Component;

import java.io.IOException;

/**
 * @author xiaohong
 * @version 1.0
 * @date 2021/11/13 0013 21:10
 * @description 死信队列消费者
 */

@Component
public class DeadConsumer {

    @RabbitListener(queues = {"dead"})
    public void receive1(Channel channel, String message, @Header(AmqpHeaders.DELIVERY_TAG) long tag) throws IOException {
        System.out.println("死信队列接收到消息：  "+message);
        channel.basicAck(tag,true);
    }

}
